<template>
  <el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item label="标题">
      <el-input v-model="form.title" />
    </el-form-item>
    <el-form-item label="是否公开">
      <el-switch v-model="form.status" />
    </el-form-item>
    <el-form-item label="内容">
      <el-input v-model="form.content" type="textarea" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="addArt">发布</el-button>
      <el-button @click="reset">重置</el-button>
    </el-form-item>
  </el-form>
</template>
<script setup>
import { issuArt } from '@/api/mange';
import router from '@/router';
import { reactive } from 'vue';
const form = reactive({
  title: '',
  content: '',
  status: ''
})
async function addArt() {
  console.log(form.title, form.content, form.status);

  await issuArt(form.title, form.content, form.status)
  // form.title = ''
  // form.content = ''
  // form.status = ''
  ElMessage.success('发布成功')
  router.push('/')
}
function reset() {
  form.title = ''
  form.content = ''
  form.status = ''
}

</script>
<style lang="scss">
.el-form {
  margin: 20px auto;
}
</style>